/*  ----------------------------------------------------------------------------
 *  Arello Mobile
 *  Fast 3d Engine
 *  ----------------------------------------------------------------------------
 * Except where otherwise noted, this work is licensed under
 * http://creativecommons.org/licenses/by/3.0
 */

#ifndef __SESSION_H__
#define __SESSION_H__

#include "Socket.hpp"
#include <string>

namespace liba
{
namespace net
{

// Deletes rw_socket in destructor!
class Session
{
public:
	explicit Session(RWSocket * rw_socket);
	bool send_message(const std::string & buf);
	const std::string& get_message();
	bool is_valid()const;
	bool operator!()const
	{
		return !is_valid();
	}
	virtual ~Session();
private:
	RWSocket * rw_socket;
	std::string msg;
//	int msg_read_len;

	int msg_required_len;
	int size_read_len;
	int size_read_msg_len;
	unsigned char size_place[4];
};

} // namespace net
} // namespace liba
using namespace liba;

#endif //__SESSION_H__